import axios from 'axios'
axios.defaults.baseURL = '106.14.183.130:8082';
axios.defaults.withCredentials = true
import jquery from 'jquery'
import qs from 'qs'
import moment from 'moment'

/* 生成树状数据结构 */
function tree(data, pid = 0, res = []) {
  data.forEach(function (row) {
    if (row.pid === pid) {
      row.children = []
      res.push(row)
      tree(data, row.id, row.children)
    }
  })
  return res
}
export default {
  install(vue, params) {
    vue.prototype.apiUrl = 'http://106.14.183.130:8082'
    vue.prototype.$http = axios
    vue.prototype.jq = jquery
    vue.prototype.$qs = qs
    vue.prototype.$tree = tree
    vue.prototype.$momnent=moment
  }
}